package saeildamil.Ch18.Critical;

public class SharedAccount {
	Account leeAccount; // 이몽룡계좌
	Account sungAccount; // 성춘향계좌

	synchronized void transfer(int amount) {
		try {
			leeAccount.withdraw(amount);
			System.out.println("이몽룡계좌인출ㅋㅋㅋ100만원ㅋㅋㅋ");
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}

		sungAccount.deposit(amount);
		System.out.println("성춘향이 계탔닼ㅋㅋ 100만원 입금!");

	}// end of transfer

	synchronized int getTotal() {
		return leeAccount.balance + sungAccount.balance;
	}

}
